package com.data.modules.online.cgform.converter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.data.common.util.MyClassLoader;
import com.data.common.util.SpringContextUtils;
import com.data.common.util.ConvertUtils;
import com.data.modules.online.cgform.entity.OnlCgformField;
import com.data.modules.online.cgform.converter.p010b.CatTreeConverter;
import com.data.modules.online.cgform.converter.p010b.DepartConverter;
import com.data.modules.online.cgform.converter.p010b.DictEasyConverter;
import com.data.modules.online.cgform.converter.p010b.DictTableConverter;
import com.data.modules.online.cgform.converter.p010b.LinkDownConverter;
import com.data.modules.online.cgform.converter.p010b.MultiSelectConverter;
import com.data.modules.online.cgform.converter.p010b.PcaConverter;
import com.data.modules.online.cgform.converter.p010b.SwitchConverter;
import com.data.modules.online.cgform.converter.p010b.TreeSelectConverter;
import com.data.modules.online.cgform.converter.p010b.UserSelectConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConvertFactory {

    private static final Logger f104a = LoggerFactory.getLogger(ConvertFactory.class);

    private static final String f105b = "list";

    private static final String f106c = "radio";

    private static final String f107d = "checkbox";

    private static final String f108e = "list_multi";

    private static final String f109f = "sel_search";

    private static final String f110g = "sel_tree";

    private static final String f111h = "cat_tree";

    private static final String f112i = "link_down";

    private static final String f113j = "sel_depart";

    private static final String f114k = "sel_user";

    private static final String f115l = "pca";

    private static final String f116m = "switch";

    public static FieldCommentConverter m130a(OnlCgformField onlCgformField) {
        String fieldShowType = onlCgformField.getFieldShowType();
        char c = 65535;
        switch (fieldShowType.hashCode()) {
            case -1624761913:
                if (fieldShowType.equals("link_down")) {
                    c = 7;
                    break;
                }
                break;
            case -889473228:
                if (fieldShowType.equals("switch")) {
                    c = 11;
                    break;
                }
                break;
            case 110798:
                if (fieldShowType.equals("pca")) {
                    c = '\n';
                    break;
                }
                break;
            case 3322014:
                if (fieldShowType.equals("list")) {
                    c = 0;
                    break;
                }
                break;
            case 45359719:
                if (fieldShowType.equals("cat_tree")) {
                    c = 6;
                    break;
                }
                break;
            case 108270587:
                if (fieldShowType.equals(f106c)) {
                    c = 1;
                    break;
                }
                break;
            case 702184024:
                if (fieldShowType.equals(f108e)) {
                    c = 2;
                    break;
                }
                break;
            case 1186535523:
                if (fieldShowType.equals("sel_tree")) {
                    c = 5;
                    break;
                }
                break;
            case 1186566288:
                if (fieldShowType.equals(f114k)) {
                    c = '\t';
                    break;
                }
                break;
            case 1536891843:
                if (fieldShowType.equals(f107d)) {
                    c = 3;
                    break;
                }
                break;
            case 1624559481:
                if (fieldShowType.equals(f113j)) {
                    c = '\b';
                    break;
                }
                break;
            case 2053565741:
                if (fieldShowType.equals("sel_search")) {
                    c = 4;
                    break;
                }
                break;
        }
        switch (c) {
            case 0:
            case 1:
                return new DictEasyConverter(onlCgformField);
            case 2:
            case 3:
                return new MultiSelectConverter(onlCgformField);
            case 4:
                return new DictTableConverter(onlCgformField);
            case 5:
                return new TreeSelectConverter(onlCgformField);
            case 6:
                return new CatTreeConverter(onlCgformField);
            case 7:
                return new LinkDownConverter(onlCgformField);
            case '\b':
                return new DepartConverter(onlCgformField);
            case '\t':
                return new UserSelectConverter(onlCgformField);
            case '\n':
                return new PcaConverter(onlCgformField);
            case 11:
                return new SwitchConverter(onlCgformField);
            default:
                return null;
        }
    }

    public static Map<String, FieldCommentConverter> m128a(List<OnlCgformField> list) {
        FieldCommentConverter a;
        HashMap hashMap = new HashMap();
        for (OnlCgformField onlCgformField : list) {
            if (ConvertUtils.isNotEmpty(onlCgformField.getConverter())) {
                a = m129a(onlCgformField.getConverter().trim());
            } else {
                a = m130a(onlCgformField);
            }
            if (a != null) {
                hashMap.put(onlCgformField.getDbFieldName().toLowerCase(), a);
            }
        }
        return hashMap;
    }

    private static FieldCommentConverter m129a(String str) {
        Object bean;
        if (str.indexOf(".") > 0) {
            try {
                bean = MyClassLoader.getClassByScn(str).newInstance();
            } catch (InstantiationException e) {
                f104a.error(e.getMessage(), e);
                bean = null;
            } catch (IllegalAccessException e2) {
                f104a.error(e2.getMessage(), e2);
                bean = null;
            }
        } else {
            bean = SpringContextUtils.getBean(str);
        }
        if (bean == null || !(bean instanceof FieldCommentConverter)) {
            return null;
        }
        return (FieldCommentConverter) bean;
    }
}
